package com.example.lcode.backtrack;

public class Question494 {
    int res;

    int findTargetSumWays(int[] nums, int target) {
        dfs(nums, target, 0);
        return res;
    }

    void dfs(int[] nums, int target, int idx) {
        if(nums.length == idx) {
            if(target == 0) {
                res ++;
            }
            return;
        }
        dfs(nums, target - nums[idx], idx + 1);
        dfs(nums, target + nums[idx], idx + 1);
    }

    public static void main(String[] args) {

    }

}
